#!/bin/bash
# 使用系统默认的 sh 运行
#################################################################################################################
# 作者：gfdgd xi
# 版本：2.2.0
# 更新时间：2022年09月24日
# 感谢：感谢 wine、deepin-wine 以及星火团队，提供了 wine、deepin-wine、spark-wine-devel 给大家使用，让我能做这个程序
# 基于 sh
#################################################################################################################

if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
	### 判断 ACE 类型
	if [[ `arch` == "loongarch64" ]]; then
    	# loongarch 架构有多个 ACE，优先安装至旧世界的 ACE
    	if [[ ! -z `which bookworm-run` ]]; then
        	aceCommand="bookworm-run"
    	fi
    	if [[ ! -z `which loongnix-run` ]]; then
        	aceCommand="loongnix-run"
    	fi
    	if [[ $aceCommand == "" ]]; then
        	echo "Oh no, ssinstall have not installed bookworm-run dependency yet! Exit"
        	#exit 1
    	fi
    	echo "Removing Wine Runner to " $aceCommand
	else
	    ###检查aptss在不在
    	if [ -z `which bookworm-run` ];then
        	echo "Oh no, ssinstall have not installed bookworm-run dependency yet! Exit"
        	#exit 1
    	fi
    	aceCommand="bookworm-run"
	fi
	# 卸载应用
	$aceCommand apt purge spark-deepin-wine-runner -y | true

else
	echo "非卸载，跳过清理"
fi
